package com.twotiger.and;

import java.util.List;

import android.content.Context;

import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.DbUtils.DaoConfig;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.exception.DbException;
import com.twotiger.and.bean.Loctionbean;

public class Dbutil {
    DbUtils dbUtils;

    public Dbutil(Context context) {
        super();

        DaoConfig config = new DaoConfig(context);
        config.setDbName("tiger");
        config.setDbVersion(1);
        dbUtils = DbUtils.create(config);
        try {
            dbUtils.createTableIfNotExist(Loctionbean.class);
        } catch (DbException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void AddAll(Loctionbean loctionbean) {
        try {
            dbUtils.saveBindingId(loctionbean);
            //			dbUtils.save(loctionbean);
        } catch (DbException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public List<Loctionbean> findAll() {
        List<Loctionbean> list = null;
        try {
            list = dbUtils.findAll(Selector.from(Loctionbean.class));
        } catch (DbException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return list;

    }

    public void DeleteAll() {
        try {
            dbUtils.deleteAll(Loctionbean.class);
        } catch (DbException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
